** Replication Code for:
** Terrorism Activates Ethnocentrism to Explain Greater Willingness to 
** Sacrifice Civil Liberties: Evidence from Germany
** Authors: Christina Novak Hansen and Peter Thisted Dinesen 
** Date: 10/02/2021

*-------------------------------------------------------------------------------

clear all
use GGSS2016_analysis.dta
svyset xs11 [pweight=wghtpew], vce(linearized)

*-------------------------------------------------------------------------------
*Appendix L: Supplementary analysis: detailed aspects of results
*-------------------------------------------------------------------------------


********************************************************************************
*L1 Findings for sociodemographic variables
********************************************************************************


									*Table L1*
					***Results with sociodemographic variables***

*Full ethnocentrism index and civil liberties (with reference to terrorism)
svy: regress st_terrori c.st_ethno i.sex st_age st_age2 i.proedu2 i.work2 if treatment1!=. 
outreg2 using Table_L1.xls, nocons stats(coef se) dec(2) symbol(**,*) alpha(0.01,0.05) label replace 
svy: regress st_terrori c.st_ethno i.treatment1 i.sex st_age st_age2 i.proedu2 i.work2 
outreg2 using Table_L1.xls, nocons stats(coef se) dec(2) symbol(**,*) alpha(0.01,0.05) label append 
svy: regress st_terrori c.st_ethno##i.treatment1 i.sex st_age st_age2 i.proedu2 i.work2 
outreg2 using Table_L1.xls, nocons stats(coef se) dec(2) symbol(**,*) alpha(0.01,0.05) label append

*Full ethnocentrism index and civil liberties (general)
svy: regress st_surveillanceindex c.st_ethno i.sex st_age st_age2 i.proedu2 i.work2 if treatment1!=. 
outreg2 using Table_L1.xls, nocons stats(coef se) dec(2) symbol(**,*) alpha(0.01,0.05) label append 
svy: regress st_surveillanceindex c.st_ethno i.treatment1 i.sex st_age st_age2 i.proedu2 i.work2 
outreg2 using Table_L1.xls, nocons stats(coef se) dec(2) symbol(**,*) alpha(0.01,0.05) label append 
svy: regress st_surveillanceindex c.st_ethno##i.treatment1 i.sex st_age st_age2 i.proedu2 i.work2 
outreg2 using Table_L1.xls, nocons stats(coef se) dec(2) symbol(**,*) alpha(0.01,0.05) label append

*Authorchild and civil liberties with reference to terrorism
svy: regress st_terrori c.st_authorchild i.sex st_age st_age2 i.proedu2 i.work2 if treatment1!=. 
outreg2 using Table_L1.xls, nocons stats(coef se) dec(2) symbol(**,*) alpha(0.01,0.05) label append 
svy: regress st_terrori c.st_authorchild i.treatment1 i.sex st_age st_age2 i.proedu2 i.work2 
outreg2 using Table_L1.xls, nocons stats(coef se) dec(2) symbol(**,*) alpha(0.01,0.05) label append 
svy: regress st_terrori c.st_authorchild##i.treatment1 i.sex st_age st_age2 i.proedu2 i.work2
outreg2 using Table_L1.xls, nocons stats(coef se) dec(2) symbol(**,*) alpha(0.01,0.05) label append
*Interaction model including both ethnocentrism and authoritarianism
svy: regress st_terrori c.st_ethno##i.treatment1 c.st_authorchild##i.treatment1 i.sex st_age st_age2 i.proedu2 i.work2 
outreg2 using Table_L1.xls, nocons stats(coef se) dec(2) symbol(**,*) alpha(0.01,0.05) label append


********************************************************************************
*L2 The activation effect on specific civil liberties measures
********************************************************************************



									*Table L2*
		***The activation effect on specific civil liberties measures***
									
									
/*" "Suppose the government suspected that a terrorist act was about to happen. 
Do you think the authorities should have the right to...detain people for as 
long as they want without putting them on trial?"*/
svy: regress st_terror1 c.st_ethno i.sex st_age st_age2 i.proedu2 i.work2 if treatment1!=. 
outreg2 using Table_L2.xls, drop(i.sex st_age st_age2 i.proedu2 i.work2) nocons stats(coef se) dec(2) symbol(**,*) alpha(0.01,0.05) label replace 
svy: regress st_terror1 c.st_ethno i.treatment1 i.sex st_age st_age2 i.proedu2 i.work2 
outreg2 using Table_L2.xls, drop(i.sex st_age st_age2 i.proedu2 i.work2) nocons stats(coef se) dec(2) symbol(**,*) alpha(0.01,0.05) label append 
svy: regress st_terror1 c.st_ethno##i.treatment1 i.sex st_age st_age2 i.proedu2 i.work2
outreg2 using Table_L2.xls, drop(i.sex st_age st_age2 i.proedu2 i.work2) nocons stats(coef se) dec(2) symbol(**,*) alpha(0.01,0.05) label append

*"... tap people’s telephone conversations?"
svy: regress st_terror2 c.st_ethno i.sex st_age st_age2 i.proedu2 i.work2 if treatment1!=. 
outreg2 using Table_L2.xls, drop(i.sex st_age st_age2 i.proedu2 i.work2) nocons stats(coef se) dec(2) symbol(**,*) alpha(0.01,0.05) label append 
svy: regress st_terror2 c.st_ethno i.treatment1 i.sex st_age st_age2 i.proedu2 i.work2 
outreg2 using Table_L2.xls, drop(i.sex st_age st_age2 i.proedu2 i.work2) nocons stats(coef se) dec(2) symbol(**,*) alpha(0.01,0.05) label append 
svy: regress st_terror2 c.st_ethno##i.treatment1 i.sex st_age st_age2 i.proedu2 i.work2 
outreg2 using Table_L2.xls, drop(i.sex st_age st_age2 i.proedu2 i.work2) nocons stats(coef se) dec(2) symbol(**,*) alpha(0.01,0.05) label append

*"... stop and search people in the street at random?"
svy: regress st_terror3 c.st_ethno i.sex st_age st_age2 i.proedu2 i.work2 if treatment1!=. 
outreg2 using Table_L2.xls, drop(i.sex st_age st_age2 i.proedu2 i.work2) nocons stats(coef se) dec(2) symbol(**,*) alpha(0.01,0.05) label append 
svy: regress st_terror3 c.st_ethno i.treatment1 i.sex st_age st_age2 i.proedu2 i.work2 
outreg2 using Table_L2.xls, drop(i.sex st_age st_age2 i.proedu2 i.work2) nocons stats(coef se) dec(2) symbol(**,*) alpha(0.01,0.05) label append 
svy: regress st_terror3 c.st_ethno##i.treatment1 i.sex st_age st_age2 i.proedu2 i.work2 
outreg2 using Table_L2.xls, drop(i.sex st_age st_age2 i.proedu2 i.work2) nocons stats(coef se) dec(2) symbol(**,*) alpha(0.01,0.05) label append


********************************************************************************
*L3 The activation effect for different levels of ethnocentrism
********************************************************************************

									*Figure L1*
		***The activation effect for different levels of ethnocentrism***

		
*Calculation of margins for different percentiles
svy: regress st_terrori c.st_ethno##i.treatment1 i.sex st_age st_age2 i.proedu2 i.work2
sum st_ethno if e(sample), detail
tab respid if e(sample) & st_ethno>0.3833333
di 130/254

margins, dydx(treatment1) at(st_ethno=(0 (0.05) 1)) vce(unconditional)
*Panel A
marginsplot, xdimension(st_ethno) name(FigureL1_PanelA, replace) recast(line) recastci(rline) ciopts(lcolor(black)) ytitle("") ytitle(, size(medsmall)) yline(0, lpattern(solid)) ylabel(-0.4(0.2)0.8, angle(horizontal) grid glpattern(shortdash)) xtitle("", size(medsmall)) xlabel(0(0.1)1, labsize(medsmall)) title("""")
graph export Figure_L1_panelA.pdf, replace

*Panel B
histogram st_ethno if treatment1!=. & sex!=. & st_age!=. & proedu2!=. & work2, bin(10) percent fcolor(gs15) lcolor(gs2) ytitle("") ylabel(, labsize(medlarge) angle(horizontal) grid glpattern(solid)) xtitle("") xtitle(, size(medlarge)) xscale(range(0 1)) xlabel(0(0.1)1, labsize(medlarge)) name(FigureL1_PanelB, replace) xsize(5) ysize(3)
graph export Figure_L1_panelB.pdf, replace

svy: regress st_terrori c.st_ethno##i.treatment1 i.sex st_age st_age2 i.proedu2 i.work2
sum st_ethno if e(sample), detail

margins, dydx(treatment1) at(st_ethno=(0.3833333)) vce(unconditional)
margins, at (treatment1=(0,1) st_ethno=(0.3833333)) vce(unconditional)

margins, dydx(treatment1) at(st_ethno=(0.9)) vce(unconditional)
margins, at (treatment1=(0,1) st_ethno=(0.9)) vce(unconditional)

*-------------------------------------------------------------------------------
